package com.ease.framework.gef4p.commands {
   import com.ease.framework.gef.EditPart;
   import com.ease.framework.gef.IEditor;
   import com.ease.framework.gef4p.model.PModel;
   import com.ease.framework.workbench.Workbench;
   import com.ease.framework.workbench.spi.impls.Command;

   public class ChangePModelNameCommand extends Command {
      private var pmodel:PModel;
      private var oldName:String;
      private var newName:String;

      public function ChangePModelNameCommand(model:PModel, name:String) {
         super();
         pmodel = model;
         oldName = pmodel.name;
         newName = name;
      }

      override public function execute():void {
         pmodel.name = newName;
         var ep:EditPart = IEditor(Workbench.instance.currentEditor).getEditDomain().getEditPartByModel(pmodel) as EditPart;
         ep.refreashFigure();
      }

      override public function undo():void {
         pmodel.name = oldName;
         var ep:EditPart = IEditor(Workbench.instance.currentEditor).getEditDomain().getEditPartByModel(pmodel) as EditPart;
         ep.refreashFigure();
      }

   }
}